<?php
	require_once('auth/autenticar.php');
	require_once('conectar.php');
	
	$resultado=false;
	$idusu=mysql_real_escape_string($_POST['idusu']);
	$result = mysql_query("SELECT * FROM members WHERE member_id=$idusu");

	if ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
		$answer='"nombre":"'.$row["firstname"].'"';
		$answer.=',"apellido":"'.$row["lastname"].'"';
		$answer.=',"usuario":"'.$row["login"].'"';
		$answer.=',"idperfil":"'.$row["idperfil"].'"';
		$answer.=',"idusu":"'.$idusu.'"';
		$result2 = mysql_query("SELECT r.id, r.nombre FROM membersXrestaurants m JOIN restaurant r ON m.idrestaurant=r.id WHERE member_id=$idusu");
		$answer2 ='{';
		$flag=false;
		while ($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)){
			if ($flag){
				$answer2.=',';
			}
			$flag=true;
			$answer2.=$row2['id'].':"'.$row2['nombre'].'"';
		}
		$answer.=',"restaurants":'.$answer2.'}';
		
	}
	$answer='{'.$answer.'}';
	echo $answer;
?>
